package cloud.xlh.infrastructure.db.service.impl;

import cloud.xlh.infrastructure.db.MyDBProperties;
import cloud.xlh.infrastructure.db.service.DBService;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 *
 * @ project name : xlh_osms
 * @ Author: XuLeHuang
 * @ Date: 2022/10/16 15:52
 * @ Description:
 */
@Configuration
@EnableConfigurationProperties(value = MyDBProperties.class)
public class DBServiceImpl implements DBService {
    private static Map<String , Integer> dbTypeMap = new HashMap<>();
    static {
        dbTypeMap.put("mysql" , 1);
        dbTypeMap.put("oracle" , 2);
    }
    @Override
    public Object getConnection(MyDBProperties myDBProperties) {
        String dbType = myDBProperties.getDbType();
        Integer dbTypeMapperNum = dbTypeMap.get(dbType);
        switch (dbTypeMapperNum) {
            case 1: {
                return doGetMySQLConnection();
            }
            case 2: {
                return doGetOracleConnection();
            }
            default: {
                ;break;
            }
        }
        return null;
    }

    private Object doGetOracleConnection() {
        return null;
    }

    private Object doGetMySQLConnection() {
        return null;
    }
}
